package com.cg.managesystem.service.impl;

import com.cg.managesystem.entity.Order;
import com.cg.managesystem.mapper.OrderMapper;
import com.cg.managesystem.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created on 2019/8/13 by Tinchi
 **/
@Service
public class OrderServiceImpl implements OrderService {

    @Autowired
    private OrderMapper orderMapper;

    @Override
    public List<Order> findAllOrders() {
        return orderMapper.selectAll();
    }

    @Override
    public Order findOrderById(Integer id) {
        return orderMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateOrderById(Order order) {
        return orderMapper.updateByPrimaryKey(order);
    }

    @Override
    public int addOrder(Order order) {
        return orderMapper.insert(order);
    }

    @Override
    public int deleteOrderById(Integer id) {
        return orderMapper.deleteByPrimaryKey(id);
    }

    //    用户创建订单
    @Override
    public int createOrder(Order order) {
        return orderMapper.createOrder(order);
    }

    @Override
    public int updateByPrimaryKey(Order order) {
        return orderMapper.updateByPrimaryKey(order);
    }
}
